﻿#include "sprite.h"

bool Sprite::isInstalled()
{
    if(!getUid().isEmpty())
        return true;
    else
        return false;
}

void Sprite::__detect()
{
    if(!isInstalled())
    {
        QString uid=QUuid::createUuid().toString();
        putUid(uid);
        int skin=sk_def;
        putSkin(skin);
    }
}

QString Sprite::getUid() const
{
    QSettings reg(e_reg,QSettings::NativeFormat);
    return reg.value("spUid").toString();
}

void Sprite::putUid(const QString &uid)
{
    QSettings reg(e_reg,QSettings::NativeFormat);
    reg.setValue("spUid",uid);
}

int Sprite::getSkin() const
{
    QSettings reg(e_reg,QSettings::NativeFormat);
    return reg.value("spSkin").toInt();
}

void Sprite::putSkin(int skin)
{
    QSettings reg(e_reg,QSettings::NativeFormat);
    reg.setValue("spSkin",skin);
}

QString Sprite::getUserName() const
{
    QSettings reg(e_reg,QSettings::NativeFormat);
    return reg.value("userName").toString();
}

void Sprite::putUserName(const QString &name)
{
    QSettings reg(e_reg,QSettings::NativeFormat);
    reg.setValue("userName",name);
}

QString Sprite::getUserNameFromEnv() const
{
    QProcessEnvironment env=QProcessEnvironment::systemEnvironment();
    return env.value(USERNAME);
}
